package com.zijidelu.luframework.plugins.tomlock.core.data;

import com.zijidelu.luframework.plugins.tomlock.core.config.LockConstant;
import lombok.Builder;
import lombok.Data;

import java.util.List;
import java.util.StringJoiner;

/**
 * 计算锁返回值。
 *
 * @author ZIJIDELU
 * @datetime 2025/4/13 23:00
 */
@Builder
@Data
public class TomLockResult {
    private List<LockResult> resultList;

    @Data
    @Builder
    public static class LockResult {
        private String module;
        private String business;
        private String uniqueKey;


        public String toRedisKey(String lockPrefix) {
            return new StringJoiner(LockConstant.LOCK_SPLIT)
                    .add(lockPrefix)
                    .add(module)
                    .add(business)
                    .add(uniqueKey)
                    .toString();
        }
    }
}
